/**
 * Created by Liuy on 2016/9/27.
 */

var addEmail = function () {

    //返回
    var gotoEmail = function () {
        $("#gotoEmail").on("click", function () {
            window.location.href = $("#email").val();
        });
    };

    //验证邮件服务器
    var verifyEmail = function () {
        $("#verifyEmailBt").on("click", function () {
            App.blockUI(window, true);
            var verify = $("#validateEmail").val();
            $("#emailEditForm").attr('action', verify);
            $("#emailEditForm").submit();
            return false;
        });
    };

    //创建、修改
    var updateEmail = function () {
        $("#updateEmailBt").on("click", function () {
            var func = $("#emailInfoId").val() != "" ? '/update' : '/create';
            var update = $("#email").val() + func;
            $("#emailEditForm").attr('action', update);
            $("#emailEditForm").submit();
            return false;
        });
    };

    return {
        init: function () {
            gotoEmail();
            verifyEmail();
            updateEmail();
            //纯数字
            var isIE8 = !!navigator.userAgent.match(/MSIE 8.0/);
            if (!isIE8) {
                $('#sysCount').bind('input propertychange', function () {
                    this.value = this.value.replace(/\D/g, '');
                });
            }
        }
    }
}();

